<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<TheWorldsWorst.ApiWrapper.Model.Question>" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title><%= Model.Title %> - TWWSOC</title>
    <link rel="Stylesheet" href="../../Content/all.css" />
</head>
<body>
<div class="container">
    <div id="header">
        <div id="topbar">
        </div>
        <br class="cbt"/>
        <div id="hlogo">
            <a href="/"><img src="../../Content/img/logo.png" alt="The World's Worst StackOverflow Clone" /></a>
        </div>
        <%= StackOverflow.Api.ExampleApp.Views.Shared.Format.Header("questions") %>
    </div>
    <div id="content">
        <div id="question-header">    
            <h2><a href="/question/<%= Model.QuestionId %>" class="question-hyperlink"><%= Model.Title %></a></h2>
        </div>
        <div id="mainbar">
            <div id="question">
                <%= StackOverflow.Api.ExampleApp.Views.Shared.Format.Question(Model) %>
            </div>
            <% if (Model.Answers.Count() > 0)
               { %>
            <div id="answers">
                <a name="tab-top"></a>
                <div id="answers-header">
                    <div id="subheader">
                        <h2><%=Model.TotalAnswers%> Answer<%= ((Model.TotalAnswers != 1) ? "s" : "")%></h2>
                        <div id="tabs">
                            <a href="javascript:return:false;" title="Answers in the order they were given">oldest</a>
                            <a href="javascript:return:false;" title="Most recent answers first">newest</a>
                            <a href="javascript:return:false;" title="Answers with the most votes first">votes</a>
                        </div>
                    </div>
                </div>
                <%
                   foreach(var a in Model.Answers)
                       Response.Write(StackOverflow.Api.ExampleApp.Views.Shared.Format.Answer(a, Model.OwnerUserId.Value));

                   if (Model.TotalAnswers > Model.Answers.Count())
                       Response.Write(StackOverflow.Api.ExampleApp.Views.Shared.Format.Pager("/question/" + Model.QuestionId.ToString(), (int)ViewData["PageNum"], (int)ViewData["PageSize"], Model.TotalAnswers > (((int)ViewData["PageSize"]) * (((int)ViewData["PageNum"]) - 1) + Model.Answers.Count())));
                %>
            </div>
            <%
                }
               else
               { %>
                    <a name="tab-top"></a>
                    <div id="answers-header">
                        <div id="subheader">
                            <h2></h2>
                            <div id="tabs">
                        </div>
                    </div>
                    </div>
             <%
               } %>
        </div> 
        <div id="sidebar" style="width:220px">
            <%= StackOverflow.Api.ExampleApp.Views.Shared.Format.QuestionSidebar(Model) %>
        </div>
        <div id="mainbar-footer">
            &nbsp;
        </div>
    </div>
</div>
</body>
</html>
